<template>
    <div>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td><input type="text" v-model="add.name"></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="add.pwd"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="登录" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref, reactive, onMounted } from "vue";
import moment from 'moment';
import { useStore } from '@/stores/ioi';
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();
const a = useStore();

let add: any = reactive({
    name: '',
    pwd: ''
})
const ok = () => {
    axios(
        {
            url: 'https://localhost:7104/api/Emp/login',
            method: 'get',
            params: add
        }
    )
        .then(res => {
            console.log(res);
            if (res.data == -1) {
                alert("用户名不存在");
                return;
            }
            if(res.data==-2)
            {
                alert("密码错误");
                return;
            }
            a.info=res.data;
            alert("登录成功")
            router.push("Hadd");
        })
}
</script>

<style scoped></style>